//
//  Kylin_SettingTableViewCell.m
//  01-LotteryBaseFrame
//
//  Created by Kylin on 16/1/9.
//  Copyright © 2016年 kylin. All rights reserved.
//

#import "Kylin_SettingTableViewCell.h"



@interface Kylin_SettingTableViewCell()



@end


@implementation Kylin_SettingTableViewCell

- (void)setItem:(Kylin_SettingItem *)item{
    _item = item;
    
    self.imageView.image = item.image;
    self.textLabel.text = item.title;
//    self.detailTextLabel.text = item.subTitle;
    
    [self setUpRightView];
}

- (void)setUpRightView{
    
    if ([self.item isKindOfClass:[Kylin_SettingArrowItem class]]) {
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }else if ([self.item isKindOfClass:[Kylin_SettingSwitchItem class]]){
        
        // 进行强制类型转换,因为item是父类类型,而需要转换成他的真实类型 ,也是就是 Kylin_SettingSwitchItem
        Kylin_SettingSwitchItem *swItem = (Kylin_SettingSwitchItem *)self.item;
        UISwitch *sw = [[UISwitch alloc] init];
        sw.on = swItem.isOpen;
        
        self.accessoryView = sw;
        
    }else{
        self.accessoryView = nil;
    }
    
    
}
// 类方法  自定义设置一个tableViw

+ (instancetype)cellViewTableView:(UITableView *)tableView{
    static NSString *ID = @"cell";
    
    Kylin_SettingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (cell == nil) {
        cell = [[Kylin_SettingTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
    }
    
    return cell;
}


@end
